package com.huawei.hianalytics.f.f;

import android.annotation.SuppressLint;
import android.content.Context;
import com.huawei.hianalytics.a.a;
import com.huawei.hianalytics.a.c;
import com.huawei.hianalytics.f.b.e;
import com.huawei.hianalytics.f.e.b;
import com.huawei.hianalytics.f.g.h;
import com.tencent.mm.opensdk.constants.ConstantsAPI.AppSupportContentFlag;

public class d implements h {
    protected Context a;
    String b;
    private String c;
    private String d;
    private String e = "oper";
    private long f;
    private String g;
    private String h;
    private Boolean i;

    public d(Context context, String str, int i, String str2, String str3, long j) {
        this.a = context;
        this.g = str;
        this.c = str2;
        this.d = str3;
        switch (i) {
            case 1:
                this.e = "maint";
                break;
            case 2:
                this.e = "preins";
                break;
            case 3:
                this.e = "diffprivacy";
                break;
            default:
                this.e = "oper";
                if (a.e(str, "oper")) {
                    b a = com.huawei.hianalytics.f.e.a.a().a(str, j);
                    this.h = a.a();
                    this.i = Boolean.valueOf(a.b());
                    break;
                }
                break;
        }
        this.f = j;
    }

    public d(Context context, String str, String str2, String str3, long j) {
        this.a = context;
        this.g = str;
        this.c = str2;
        this.d = str3;
        this.e = "oper";
        this.f = j;
        if (a.e(str, "oper")) {
            b a = com.huawei.hianalytics.f.e.a.a().a(str, j);
            this.h = a.a();
            this.i = Boolean.valueOf(a.b());
        }
    }

    @SuppressLint({"ApplySharedPref"})
    private void a() {
        int l = com.huawei.hianalytics.a.b.l();
        int h = c.h(this.g, this.e);
        if (h.a(this.a, "stat_v2_1", l * 1048576)) {
            com.huawei.hianalytics.g.b.b("HiAnalytics/event", "stat sp file reach max limited size, discard new event");
            i.a().a("", "");
            return;
        }
        e eVar = new e();
        eVar.d(this.c);
        eVar.f(com.huawei.hianalytics.f.g.d.b(this.d, this.a));
        eVar.g(this.g);
        eVar.e(this.e);
        eVar.c(String.valueOf(this.f));
        eVar.a(this.h);
        eVar.b(this.i == null ? null : this.i + "");
        eVar.h(this.b);
        long a = eVar.a(this.a);
        if (a > ((long) h) * AppSupportContentFlag.MMAPP_SUPPORT_XLS) {
            com.huawei.hianalytics.g.b.b("EventRecordTask", "begin autoReport..eventLength: " + a);
            i.a().a(this.g, this.e);
        }
    }

    public void run() {
        com.huawei.hianalytics.g.b.b("EventRecordTask", "event record task running");
        a();
    }
}
